import { Promise } from 'es6-promise'
import { convertParams, convertRequestURL, localInfo, getQueryString, Storage } from '../utils/utils'
import  store  from '../vuex/store'
import  { showLoading, hideLoading, setMsgTip, setUserId, setCity, setNeedLogin }  from '../vuex/actions'


// errorCodeHandle
const errorCodeHandle = (resp,reject,nullTip)=>{
    if(resp.code){
        if(resp.code == 204){
            setMsgTip(store,{
                text:resp.msg,
                type:'error'
            })
            reject(new Error(resp.msg))
            return true
        }
        else if(resp.code == 401 || resp.code == 23003 ){
            setMsgTip(store,{
                text:resp.msg,
                type:'error'
            })
            setNeedLogin(store, true)
            reject(new Error(resp.msg))
            return true
        }
        setMsgTip(store, {
            text:resp.msg,
            type:'warn'
        })
        reject(new Error(resp.msg))
        return true
    }
    if(nullTip){
        if(!resp.data){
            setMsgTip(store, {
                text:resp.msg,
                type:'warn'
            })
            reject(new Error(resp.msg))
            return
        }
    }
    return false
}

// errorRequestHandle
const errorRequestHandle = (text,reject)=>{
    setMsgTip(store,{
        text:text,
        type:'error'
    })
    reject(new Error(text));
}
// 渠道管理
const channelApi={
    channelroviderPList(params){
        return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                 headers: {
                        channel: "abc"
                    },
                url: convertRequestURL("channel/channelroviderPList"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求渠道商信息列表失败',reject)
                }
            });
        })
    },
    channelManageajax(params){
         return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("channel/channelManage"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求新增渠道商失败',reject)
                }
            });
        })
    },
    channelProviderDOList(params){
        return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("channel/channelProviderDOList"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求渠道商列表失败',reject)
                }
            });
        })
    },
    channelNumberDOList(params){
        return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("channel/channelNumberDOList"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求渠道商相应渠道号失败',reject)
                }
            });
        })
    },
    addChannelCode(params){
        return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("channel/channelCodeManage"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求新增渠道号失败',reject)
                }
            });
        })
    }
}
//渠道实时查询
const channelRealtime={
    channelRealtimeDataList(params){
        return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("channel/channelRealtimeDataList"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求渠道实时查询失败',reject)
                }
            });
        })
    },
    channelNumberDOList(params){
         return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("channel/channelNumberDOList"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    resolve(data)
                },
                error(){
                    errorRequestHandle('请求实时查询渠道号失败',reject)
                }
            });
        })
    }
}
const loginApi = {
    userLogin(params){
        return new Promise(function(resolve, reject){
            $.ajax({
                type:"post",
                url: convertRequestURL("sysUser/login","youjieB"),
                data:params,
                dataType:"json",
                success: (resp) => {
                    let isError = errorCodeHandle(resp,reject)
                    if(isError) return

                    let data = resp.data
                    setMsgTip(store, {
                        text:'登录成功',
                        type:'success'
                    })
                    resolve(data)
                },
                error(){
                    errorRequestHandle('登录失败',reject)
                }
            });
        })
    }
}
const allApi = {
     addScoreConfig(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("/scoreConfig/addScoreConfig","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求点券价格及数量失败！', reject)
            }
        });
        })
    },
    initPrice(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("/scoreConfig/initPrice","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求所有借款初始价格失败！', reject)
            }
        });
        })
    }
    ,findAll(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("sysUser/findAll","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    //菜单栏目接口
    list(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"get",
            url: convertRequestURL("sysMenu/list","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求所有菜单栏目失败！', reject)
            }
        });
        })
    },
    save(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("sysUser/save","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求修改失败！', reject)
            }
        });
        })
    },
    findPage(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("sysUser/findPage","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求分页显示失败！', reject)
            }
        });
        })
    },
    // 排序接口
    findAllCreateTimeDesc(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("sysUser/findAllCreateTimeDesc","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求分页显示失败！', reject)
            }
        });
        })
    },
    addExpansionManager(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("sysUser/addExpansionManager","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求添加拓展经理失败！', reject)
            }
        });
        })
    },
    // 放款人管理
    searchUser(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/searchUser","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求添加放款人管理未审核失败！', reject)
            }
        });
        })
    },
    updateChargeTag(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/updateChargeTag","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求修改充值标签失败！', reject)
            }
        });
        })
    },
    // 查询拓展经理
    findManager(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/findManager","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求添加放款人管理未审核失败！', reject)
            }
        });
        })
    },
    //cpa 此块接口
    findAllTwo(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("order/findAll","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    //借款需求
    borrowDemanded(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("borrow/findAll","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    //新的接口
    findAllAllocationStr(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("order/findAllAllocationStr","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    borrowNeed(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("borrow/findAllBorrowStateStr","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    updateAllocation(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/updateAllocation","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    changerScore(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("borrow/changerScore","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    baseCheck(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("borrow/baseCheck","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // 批量修改api
    batchUpdateAllocation(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/batchUpdateAllocation","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    orderList(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"get",
            url: convertRequestURL("borrow/orderList","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // 六种状态下的查询
    checkState(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/check","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    scoreRecord(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"get",
            url: convertRequestURL("scoreRecord/list","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // POST /user/findAllAllocationStr
    // 展示放款人管理的拓展标签
    findAllAllocationStrUser(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/findAllAllocationStr","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    userLogType(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/log","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // user/addFollowRecord
    addFollowRecord(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/addFollowRecord","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // user/relieve
    relieve(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("user/relieve","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // workAuth/examine
    examine(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"get",
            url: convertRequestURL("workAuth/examine","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // LendRecord/findAllLendRecord
    // 列表
    findAllLendRecord(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("LendRecord/findAllLendRecord","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // LendRecord/findAllAllocationStr
    // 分配
    findAllAllocationStrNew(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("LendRecord/findAllAllocationStr","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // LendRecord/check
    LendRecordCheck(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("LendRecord/check","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // LendRecord/ApplyRecord
    ApplyRecord(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("LendRecord/ApplyRecord","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // rechargeRecord/findAllRechargeRecord
    findAllRechargeRecord(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("rechargeRecord/findAllRechargeRecord","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // rechargeRecord/findAllAllocationStr
    rechargeRecordFindAllAllocationStr(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("rechargeRecord/findAllAllocationStr","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // scoreConfig/findAllScoreConfig
    findAllScoreConfig(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("scoreConfig/findAllScoreConfig","youjieB"),
            dataType:"json",
            data:params,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // InputPieceApplyOrderManage/findAll
    InputPieceApplyOrderManage(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("InputPieceApplyOrderManage/findAll","youjieB"),
            dataType:"json",
            data:params,
            // contentType:'application/json;charset=UTF-8', 
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // InputPieceApplyManage/findAllInputPieceApplyManage
    findAllInputPieceApplyManage(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"POST",
            url: convertRequestURL("InputPieceApplyManage/findAllInputPieceApplyManage","youjieB"),
            dataType:"json",
            data:params,
            // contentType:'application/json;charset=UTF-8', 
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // version/list
    versionList(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"GET",
            url: convertRequestURL("version/list","youjieB"),
            dataType:"json",
            data:params,
            // contentType:'application/json;charset=UTF-8', 
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // version/save andriod
    versionSave(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"GET",
            url: convertRequestURL("version/save","youjieB"),
            dataType:"json",
            data:params,
            // contentType:'application/json;charset=UTF-8', 
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // version/update
    versionUpdate(params){
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"GET",
            url: convertRequestURL("version/update","youjieB"),
            dataType:"json",
            data:params,
            // contentType:'application/json;charset=UTF-8', 
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return

            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    //gernaralization  Overview/findAllI
    OverviewfindAll(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("Overview/findAll","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // demandPrice/findAll
    demandPricefindAll(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("demandPrice/findAll","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // demandPrice/save
    demandPricesave(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("demandPrice/save","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // creditReport/find
    creditReportfind(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("creditReport/find","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // creditReport/update
    creditReportupdate(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("creditReport/update","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // helps/findAll
    helpsfindAll(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("helps/findAll","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // helps/findByPrimaryKey
    findByPrimaryKey(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("helps/findByPrimaryKey","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // helps/update
    helpspdate(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("helps/update","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // feedBack/findAll
    feedBackfindAll(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("feedBack/findAll","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // banner/findAllC
    bannerfindAllC(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("banner/findAllC","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    bannerupload(file){
        let formData = new FormData();
        formData.append('file', file);
        return new Promise( (resolve, reject) => {
        $.ajax({
            type:"post",
            url: convertRequestURL("banner/upload","youjieB"),
            global:false,
            cache: false,
            contentType: false,   
            processData: false,
            data:formData,
            success: (resp) => {
            let isError = errorCodeHandle(resp,reject)
            if(isError) return
    
            let data = resp.data
            resolve(data)
            },
            error(){
            errorRequestHandle('请求失败！', reject)
            }
        });
        })
    },
    // banner/compile
    bannersave(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("banner/compile","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // banner/save
    bannersavei(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("banner/save","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // banner/findAllB
    bannerfindAllB(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("banner/findAllB","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // invitePrize/updateRule
    invitePrizeupdateRule(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("invitePrize/updateRule","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // invitePrize/updatePrize
    invitePrizeupdatePrize(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("invitePrize/updatePrize","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // invitePrize/findAllUser
    digfinally(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("invitePrize/findAllUser","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // invitePrize/saveRule
    invitePrizeaveRule(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("invitePrize/saveRule","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // banner/findAllB
    bannerfindAllB(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("banner/findAllB","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // 弹窗广告
    // popupAds/findAll
    popupAdsfindAll(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("popupAds/findAll","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // popupAds/find
    popupAdsfind(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("popupAds/find","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // popupAds/delete
    popupAdsdelete(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("popupAds/delete","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
    // popupAds/add
    popupAdsadd(params){
        return new Promise((resolve,reject) =>{
            $.ajax({
                type:"POST",
                url: convertRequestURL("popupAds/add","youjieB"),
                dataType:"json",
                data:params,
                // contentType:'application/json;charset=UTF-8', 
                success: (resp) => {
                let isError = errorCodeHandle(resp,reject)
                if(isError) return
    
                let data = resp.data
                resolve(data)
                },
                error(){
                errorRequestHandle('请求失败！', reject)
                }
            })
        })
    },
}

export {
    allApi,
    loginApi,
    channelRealtime,
    channelApi
 }
